<h1>Editar Maquina</h1>
<% content_for :googlemaps do %>
  <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
  <script type="text/javascript">
    var centro = new google.maps.LatLng(<%= @maquina.latitud %>,<%= @maquina.longitud %>);
    var marker;
    var map;
    var point;

    function initialize() {
      var mapOptions = {
        zoom: 14,
        mapTypeId: google.maps.MapTypeId.HYBRID,
        center: centro
      };

      map = new google.maps.Map(document.getElementById("map_canvas"),
      mapOptions);

      marker = new google.maps.Marker({
        map:map,
        draggable:true,
        animation: google.maps.Animation.DROP,
        position: centro
      });
      google.maps.event.addListener(marker, 'click', toggleBounce);
      google.maps.event.addListener(marker, 'dragend', coordinates);
    }

    function toggleBounce() {
      if (marker.getAnimation() != null) {
        marker.setAnimation(null);
      } else {
        marker.setAnimation(google.maps.Animation.BOUNCE);
      }
    }

    function coordinates() {
      var point = new google.maps.LatLng(marker.getPosition().lat(),marker.getPosition().lng(),true);
      map.panTo(point);
      document.getElementById("maquina_latitud").value = point.lat();
      document.getElementById("maquina_longitud").value = point.lng();
    }

  </script>
<% end %>

<%= error_messages_for 'maquina', :header_message => nil  , :message => nil %>
<table>
<% form_for(@maquina) do |f| %>
  <%#= f.error_messages %>
  <div align="center">
    <tr>
        <td>
            <p>
              <%= f.hidden_field(:latitud) %>
              <%= f.hidden_field(:longitud) %>
            </p>
              <p>
              <%= f.label :nombre %><br />
              <%= f.text_field :nombre %>
            </p>
              <p>
              <%= f.label :descripcion %><br />
              <%= f.text_field  :descripcion%>
            </p>
             <p>
              <%= f.label :status %><br />
              <%= f.select(:status, [['Activa','activa'], ['Inactiva','inactiva']]) %>
            </p>
            <div  id="map_canvas" style="width:400px; height:210px"> </div>
            <p>
              <%= f.submit 'Update' %>
            </p>
        </td>
    </tr>
  </div>
<% end %>
</table>
<div align="center"><%= link_to '<img src="/images/back.png" alt="" width="40" height="40" />', maquinas_path %></div>
<div align="center"><%= link_to 'Regresar' , maquinas_path%> </div>

